﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Label3.Text = System.DateTime.Now.ToString();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //ViewState["text"] = TextBox1.Text;
            //ViewState["text1"] = TextBox2.Text;
            //ViewState["text2"] = TextBox3.Text;
            if (Page.IsPostBack)//如果IsPostBack是true，就是说明是页面回发，否则就是首次加载这个页面。
            {
                if (TextBox1.Text == "")
                {
                TextBox1.Text = "请输入内容";
                }
                else if(TextBox2.Text == "")
                {
                TextBox2.Text = "请输入内容";
                }
                else if(TextBox3.Text == "")
                {
                TextBox3.Text = "请输入内容";
                }
            }
            if (TextBox1.Text == "请输入内容" | TextBox2.Text == "请输入内容" | TextBox3.Text == "请输入内容")
            {
                Label4.Text = "请填写完整！";
            }
            else
            {
                Label4.Text = "请确认你填写的信息：";
                Label5.Text = "姓名:" + TextBox1.Text;
                Label6.Text = "年龄:" + TextBox2.Text;
                Label7.Text = "爱好:" + TextBox3.Text;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //if (!IsPostBack)//首次加载页面
            //{
            //    ViewState["text"] = 0;
            //}
            
            //else
            //{

            //Label4.Text ="请确认你填写的信息"+ Convert.ToString(ViewState["text"])+ Convert.ToString(ViewState["text1"])+ Convert.ToString(ViewState["text2"]);
            //}
        }
    }
}